//
//  SearchRoutePoiQueryModel.m
//  o_amap
//
//  Created by Q神 on 2021/4/19.
//

#import "SearchRoutePoiQueryModel.h"
#import "MJExtension.h"

@implementation SearchRoutePoiQueryModel

+ (AMapRoutePOISearchRequest *)searchRoutePoiLine:(NSString *)query {
    SearchRoutePoiQueryModel *routePoiQueryModel = [SearchRoutePoiQueryModel mj_objectWithKeyValues:query];
    
    AMapRoutePOISearchRequest *request = [[AMapRoutePOISearchRequest alloc] init];
    request.origin = [AMapGeoPoint locationWithLatitude:[routePoiQueryModel.from.latitude doubleValue]
                                              longitude:[routePoiQueryModel.from.longitude doubleValue]];
    request.destination = [AMapGeoPoint locationWithLatitude:[routePoiQueryModel.to.latitude doubleValue]
                                                   longitude:[routePoiQueryModel.to.latitude doubleValue]];
    request.searchType = routePoiQueryModel.searchType;
    request.strategy = routePoiQueryModel.mode;
    request.range = routePoiQueryModel.range;
    NSMutableArray<AMapGeoPoint *> *arrays = [NSMutableArray array];
    for (LatLngModel *point in routePoiQueryModel.polylines) {
        [arrays addObject:[AMapGeoPoint locationWithLatitude:[point.latitude doubleValue] longitude:[point.longitude doubleValue]]];
    }
    request.polyline = arrays;
    return request;
}

@end
